package com.itheima.HomeWork;

import java.util.HashMap;
import java.util.Scanner;
import java.util.function.BiConsumer;

public class Demo06 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        System.out.print("请输入字符串:");
        String str=scanner.nextLine();
        HashMap<Character, Integer> strs= new HashMap<>();

        for(int i=0;i<str.length();i++){
            if(str.charAt(i)!=' '){
                if(strs.containsKey(str.charAt(i))){
                    int v=strs.get(str.charAt(i));
                    v++;
                    strs.put(str.charAt(i),v);
                }else{
                    strs.put(str.charAt(i),1);
                }
            }
        }
        System.out.println(strs);
        strs.forEach(new BiConsumer<Character, Integer>() {
            @Override
            public void accept(Character character, Integer integer) {
                System.out.print(character+"("+integer+")");
            }
        });
    }
}
